using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ThxStuFish : MonoBehaviour
{
    private Animator animator;
    private Rigidbody2D myRigidbody;
    private BoxCollider2D myfeet;
    public float Runspeed;
    void Killplayer()
    {
        if (Time.timeScale > 0)
        {
            Vector2 vel = new Vector2(0, myRigidbody.velocity.y);
            myRigidbody.velocity = vel;
            Time.timeScale = 0f;
            //TestGameRoot.Instance.scenesystem.scenestate.panelmanager.Push(new LossPanel());
#if UNITY_EDITOR
            UnityEditor.EditorApplication.isPlaying = false;
#else
                 Application.Quit();
#endif
            //Destroy(gameObject);
        }

    }
    public void Start()
    {
        animator = GetComponent<Animator>();
        myRigidbody = GetComponent<Rigidbody2D>();
        myfeet = GetComponent<BoxCollider2D>();
        transform.localRotation = Quaternion.Euler(0, 180, 0);


        
    }
    void Flip()
    {
      transform.localRotation = Quaternion.Euler(0, 180, 0);
    }
    void Move()
    {
        //animator.SetTrigger("move");
        animator.SetBool("move1", true);
        Vector2 vel = new Vector2( Runspeed, myRigidbody.velocity.y);
            myRigidbody.velocity = vel;

    }
    // Update is called once per frame
    //void Attack()
    //{
    //   if (Input.GetKeyDown(KeyCode.J))
    //   {
    //      animator.SetTrigger("attack");
    //Vector2 vel = new Vector2(myRigidbody.velocity.x,0);
    // myRigidbody.velocity = vel;
    // tempvel = myRigidbody.velocity;
    //  myRigidbody.Sleep();

    //  }
    //  else
    // {
    // //    if (myRigidbody.IsSleeping())
    //  {
    //      myRigidbody.WakeUp();
    //       myRigidbody.velocity=tempvel;
    //
    //   }

    // }
    //}
    public void Update()
    {


                Flip();
                Move();
        //Attack();
        if (transform.position.y < -20f)
        {
            Killplayer();
        }

    }
}

